package com.jzo2o.customer.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.jzo2o.common.expcetions.ForbiddenOperationException;
import com.jzo2o.common.model.CurrentUserInfo;
import com.jzo2o.common.utils.JwtTool;
import com.jzo2o.customer.mapper.BankAccountMapper;
import com.jzo2o.customer.model.domain.BankAccount;
import com.jzo2o.customer.model.dto.request.BankAccountUpsertReqDTO;
import com.jzo2o.customer.service.BankAccountService;
import io.swagger.annotations.ApiOperation;
import net.bytebuddy.implementation.bytecode.Throw;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author Administrator
* @description 针对表【bank_account(银行账户)】的数据库操作Service实现
* @createDate 2024-08-19 19:43:17
*/
@Service
public class BankAccountServiceImpl extends ServiceImpl<BankAccountMapper, BankAccount>
    implements BankAccountService {

    @Autowired
    protected BankAccountMapper bankAccountMapper;

    @Autowired
    JwtTool jwtTool;

    @Override
    public BankAccount currentUserBankAccount(String token) {
        //解析token
        CurrentUserInfo currentUserInfo = jwtTool.parseToken(token);
        //如果token为空,不能获取用户信息
        if (currentUserInfo == null) {
            throw new ForbiddenOperationException("token不能为空");
        }
        //根据Id获取账户信息
        return bankAccountMapper.selectById(currentUserInfo.getId());


    }


}




